Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 16, 2025

This PR resolves the inconsistency between SdkLogger and SdkTracer by adding Clone implementation to SdkLogger.

Problem

Currently, SdkTracer implements Clone but SdkLogger does not, creating an inconsistent API experience:

// SdkTracer can be cloned
let tracer = tracer_provider.tracer("my-tracer");
let cloned_tracer = tracer.clone(); // ✅ Works

// SdkLogger cannot be cloned
let logger = logger_provider.logger("my-logger"); 
let cloned_logger = logger.clone(); // ❌ Compilation error

This forces users to wrap SdkLogger in Arc or similar constructs when they need to share it across multiple contexts.

Solution

Added Clone to the derive macro for SdkLogger. This is safe because both fields in the struct already implement Clone:

  • InstrumentationScope implements Clone
  • SdkLoggerProvider implements Clone

Changes

  • Modified SdkLogger from #[derive(Debug)] to #[derive(Debug, Clone)]
  • Added a test to verify the Clone functionality works correctly

After this change

// Both now work consistently
let tracer = tracer_provider.tracer("my-tracer");
let cloned_tracer = tracer.clone(); // ✅ Works

let logger = logger_provider.logger("my-logger"); 
let cloned_logger = logger.clone(); // ✅ Now works too!

This is a non-breaking change that improves API consistency and developer experience.

Fixes #3058.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 16, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: cijothomas / name: Cijo Thomas (73d00d3)

@codecov
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.1%. Comparing base (0631070) to head (73d00d3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main   #3072     +/-   ##
=======================================
- Coverage   80.2%   80.1%   -0.1%     
=======================================
  Files        126     126             
  Lines      21949   21949             
=======================================
- Hits       17604   17603      -1     
- Misses      4345    4346      +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI changed the title [WIP] inconsistency with Clone implementations for SdkLogger / SdkTracer Add Clone implementation to SdkLogger for API consistency with SdkTracer Jul 16, 2025
Copilot AI requested a review from cijothomas July 16, 2025 16:34
Copilot finished work on behalf of cijothomas July 16, 2025 16:34
Copilot finished work on behalf of cijothomas July 16, 2025 16:43
Copilot AI requested a review from cijothomas July 16, 2025 16:43
@cijothomas cijothomas changed the title Add Clone implementation to SdkLogger for API consistency with SdkTracer feat: Add Clone implementation to SdkLogger for API consistency with SdkTracer Jul 16, 2025
@cijothomas cijothomas force-pushed the copilot/fix-3058-2 branch from 26f5f51 to 73d00d3 Compare July 16, 2025 16:55
@cijothomas cijothomas marked this pull request as ready for review July 16, 2025 16:55
@cijothomas cijothomas requested a review from a team as a code owner July 16, 2025 16:55
@cijothomas cijothomas merged commit 0e3511e into main Jul 16, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

inconsistency with Clone implementations for SdkLogger / SdkTracer

3 participants